#/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd $DIR

mkdir -p ~/.ssh

cp -f id_rsa ~/.ssh/
chmod 600 ~/.ssh/id_rsa

cp -f id_rsa.pub ~/.ssh/
chmod 664 ~/.ssh/id_rsa.pub

cp -f config ~/.ssh/
chmod 664 ~/.ssh/config

if [ ! -f id_rsa.pub ]; then
    touch ~/.ssh/authorized_keys
fi
cat host_id_rsa.pub >> ~/.ssh/authorized_keys
cat id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

popd